-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Client example of fetching data for Next.js app router using the fetch API #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Client example of fetching data for Next.js app router using the fetch API #74
Conversation
Added scripts for wp-env to setup example fo rnext.js app. Still a bit to sort and added the start of the README.md
…ub.com:wpengine/hwptoolkit into example-data-fetch-nextjs-app-router-fetch-api
examples/client/single-site-setup/nextjs-app-router-fetch-api/.wp-env.json
Show resolved
Hide resolved
Added more posts for pagination. Added more CPT events too. Content generated by Claude.
- Restructured based on merged PRs - Moved any wp-env assets under wp-env to make it cleaner for a developer - Updated README.md with install - Removed uploads directory - Added agents.json for AI LLMs
Renamed template structure as per #89 Added boilerplate templates with dummy content to be filled. Added header/footer
Fixed issue with having to flush permalinks once the DB was imported. Fixed issue with CORS for requests from localhost:3000
Refactord all 3 templates to use the same template components Added Posts Per Page as a variable in the next config too.
Also exported the database with some new content.
|
@josephfusco @theodesp @moonmeister @whoami-pwd @ahuseyn The current state of this PR is: Complete
What is left to do
Other notes for testing
Screenshots
|
- Added featured image component - Changed WP GraphQL zip file as currently the latest release is broken - Fixed up event listing templates - Set version 10 for PNPM
|
Just noting design is based off @ahuseyn example for the Next.js Pages router. |
ahuseyn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks amazing @colinmurphy. It became a very detailed and comprehensive example. I've followed the instructions of readme file and was just a smooth setup experience 🚀🚀🚀.
Just suggested one small typo fix from the readme.
Co-authored-by: Huseyn Aghayev <[email protected]>
Thanks @ahuseyn ❤️ 🚀 Thanks for spending so much time reviewing and testing this. Also for your helpful feedback earlier in the PR process on the setup. I have committed your suggestion. |
ahuseyn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks amazing @colinmurphy. It became a very detailed and comprehensive example. I've followed the instructions of readme file and was just a smooth setup experience 🚀🚀🚀.
Just suggested one small typo fix from the readme.Thanks @ahuseyn ❤️ 🚀 Thanks for spending so much time reviewing and testing this. Also for your helpful feedback earlier in the PR process on the setup.
I have committed your suggestion.
It's a pleasure, glad if I could help!





Screencast (3 mins long)
Screencast.mov
Example: Next.js App Router using the Fetch API
Table of Contents
Overview
Running the Example with wp-env
Overview
An example headless WordPress application using Next.js App Router and the fetch API to fetch data from WordPress using WPGraphQL It showcases different data fetching strategies, state management techniques, and modern web development patterns in a real-world application context. This also contains a full example using wp-env and sample data.
Prerequisites
Project Structure
Features
Covers various rendering patterns of Next.js
Blog features
Other Template Features
Screenshots
See screenshot directory
Running the example with wp-env
Prerequisites
Note Please make sure you have all prerequisites installed as mentioned above and Docker running (
docker ps)Setup Repository and Packages
git clone https://github.com/wpengine/hwptoolkit.gitexamples/next/client-app-router-fetch-data/example-appwith"NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8888e.g.
Build and start the application
cd examples/next/client-app-router-fetch-datapnpm example:buildwill build and start your application.wp-env/uploads.ziptowp-env/uploadswhich is mapped to the wp-content/uploads directory for the Docker container.example-appCongratulations, WordPress should now be fully set up.
Command Reference
example:buildexample:devexample:dev:installexample:startexample:stopexample:prunewp:startwp:stopwp:destroywp:db:querywp:db:exportwp-env/db/database.sql.wp:db:importwp-env/db/database.sql.wp:images:unzipwp:images:zipDatabase access
If you need database access add the following to your wp-env
"phpmyadminPort": 11111,(where port 11111 is not allocated).You can check if a port is free by running
lsof -i :11111